<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
  <title>pie_data_japanese (Fusioncharts::Utf8ExampleController)</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
</head>
<body class="standalone-code">
  <pre><span class="ruby-comment cmt"># File app/controllers/fusioncharts/utf8_example_controller.rb, line 48</span>
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">pie_data_japanese</span>
    
      <span class="ruby-identifier">headers</span>[<span class="ruby-value str">&quot;Content-Type&quot;</span>] = <span class="ruby-value str">&quot;text/xml; charset=utf-8&quot;</span>  <span class="ruby-comment cmt"># xml content with charset=uttf-8</span>

      <span class="ruby-ivar">@factory_data</span> = []
      
      <span class="ruby-comment cmt"># Find all the factories</span>
      <span class="ruby-identifier">factory_masters</span> = <span class="ruby-constant">Fusioncharts</span><span class="ruby-operator">::</span><span class="ruby-constant">JapaneseFactoryMaster</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">:all</span>)
     
      <span class="ruby-comment cmt"># For each factory, find the factory output details.</span>
        <span class="ruby-identifier">factory_masters</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">factory_master</span><span class="ruby-operator">|</span>
          <span class="ruby-identifier">factory_name</span> = <span class="ruby-identifier">factory_master</span>.<span class="ruby-identifier">name</span>  
          <span class="ruby-identifier">total</span> = <span class="ruby-value">0</span><span class="ruby-value">.0</span>
          <span class="ruby-identifier">factory_master</span>.<span class="ruby-identifier">factory_output_quantities</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">factory_output</span><span class="ruby-operator">|</span>
            <span class="ruby-comment cmt"># Total the output quantity for a particular factory</span>
            <span class="ruby-identifier">total</span> = <span class="ruby-identifier">total</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">factory_output</span>.<span class="ruby-identifier">quantity</span>
          <span class="ruby-keyword kw">end</span>
          <span class="ruby-comment cmt"># Append the array of factory name and total output quantity to the existing array @factory_data</span>
          <span class="ruby-ivar">@factory_data</span><span class="ruby-operator">&lt;&lt;</span>[<span class="ruby-identifier">factory_name</span>,<span class="ruby-identifier">total</span>]
      <span class="ruby-keyword kw">end</span>
    <span class="ruby-keyword kw">end</span></pre>
</body>
</html>